* File to import game data from Lumosity

***inputs:
*  $GameOrigData/la_nauze_game_data_anon_gameid`g'.csv for g  in 55 74 76 77 78 84 104

***outputs:
* $Data/GameData.dta


* import raw data 
foreach g  in 55 74 76 77 78 84 104 {
	clear
insheet using $OrigData/la_nauze_game_data_anon_gameid`g'.csv
	gen gamenum = `g'
save $Data/GameData`g'.dta, replace
	}
		
		
use $Data/GameData55.dta, clear
	
	foreach g  in 74 76 77 78 84 104 {
	
	append using $Data/GameData`g'.dta
	
erase $Data/GameData`g'.dta
	}
	
	erase $Data/GameData55.dta
	

* transform string date to stata date
	gen date_str = substr(game_timestamp_local,1,10)
	gen date = date(date, "YMD") 
	format date %td

	gen double time_stamp = clock(game_timestamp_local,"YMDhms")
	format time_stamp %tc
	label variable time_stamp "Local time"

* define value labels and label values
	label define dowval 0 "Monday" 1 "Tuesday" 2 "Wednesday" 3 "Thursday" 4 "Friday" 5 "Saturday" 6 "Sunday"
	label values day_of_week dowval

	gen hour = hhC(time_stamp)

* label variables
	label variable nth_play "Number of plays"
	label variable day_of_week "Day of week"
	label variable hour "Hour of day"
	
	
save $Data/GameData.dta, replace


